package com.zyj.utils.maths;

/**
 * 数学工具类
 */
public class MathUtils {
    /**
     * 如果一个数 A <= APPROACH_ZERO， 则认为A == 0
     */
    private static final double APPROACH_ZERO = 0.0000001;

    /**
     * 判断num是否是0
     * @param num
     * @return
     */
    public static boolean isZero(double num){
        return num <= APPROACH_ZERO;
    }

    /**
     * 获取最小值
     * @param nums
     * @return
     */
    public static double getMinNum(double... nums){
        if(nums == null || nums.length == 0){
            throw new IllegalArgumentException("At least one num should be given");
        }
        double min = nums[0];
        for (int i = 1; i < nums.length; i++) {
            min = nums[i] < min ? nums[i] : min;
        }
        return min;
    }

}
